import Vue from "vue";
import template from "./intro.vue";

let instance;
function initIntro() {
  if (!instance) {
    initTemplate();
  }
}
function initTemplate() {
  const Intro = Vue.extend(template);
  instance = new Intro();
  instance.$mount(document.createElement("div"));
  document.body.appendChild(instance.$el);
}

export function intro({ steps, options = {} }) {
  initIntro();
  instance.start(steps, options);
}
export default {
  install(Vue) {
    Vue.prototype.$intro = intro;
  },
};
